package cn.ldw.controller;

import cn.ldw.pojo.User;
import cn.ldw.service.UserService;
import cn.ldw.vo.UserParams;
import cn.ldw.vo.LoginParams;
import cn.ldw.vo.ModifyParams;
import cn.ldw.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/click")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public Result login(@RequestBody LoginParams loginParams) {
        return userService.login(loginParams);
    }

    @RequestMapping("/info")
    public Result info() {
        return userService.info();
    }

    @RequestMapping("/register")
    public Result register(@RequestBody LoginParams loginParams) {
        return userService.register(loginParams);
    }

    @RequestMapping("/logout")
    public Result loginout(@RequestHeader("Authorization") String token) {
        return  userService.loginout(token);
    }

    @RequestMapping("/modify")
    public Result modify(@RequestBody ModifyParams modifyParams) {
        return userService.modify(modifyParams);
    }

    @RequestMapping("/userInfo")
    public Result userInfo() {
        return userService.userInfo();
    }

    @RequestMapping("/addUser")
    public Result addUser(@RequestBody UserParams userParams) {
        return userService.addUser(userParams);
    }

    @RequestMapping("/delete")
    public Result delete(@RequestBody User user) {
        return userService.delete(user);
    }

    @RequestMapping("/modifyUser")
    public Result modifyUser(@RequestBody UserParams userParams) {
        return userService.modifyUser(userParams);
    }
}
